function Jumppages(selector){
	this.ele = $(selector).get(0);
	$(this.ele).find('li').on({
		'click':function(){
			this.index=$(this).index();
			if(this.index==0){
				window.open("landingpage.html");
			}else if(this.index==1){
				window.open("registerpage.html");
			}else if(this.index==3){
				window.open("shopcat.html");
			}	
		}
	})
	
}

function Scrolltop(selector) {
	this.ele = $(selector).get(0);
	this.up = $('.showup').get(0);
	this.mouseaction();
	
}
Scrolltop.prototype.mouseaction = function() {
		oself = this;
		var length = $(oself.up).find('li').size();
		$(oself.up).find(' li').on({
			'mouseenter mouseleave ': function() {
				this.index = $(this).index();
				if(this.index == 1) {
					$('.show').toggle();
				} 
			},
			'click': function() {
				oself = this;
				 if(oself.index == length - 1) {
					$(window).scrollTop(0)
				}else if(oself.index ==length - 2){
					window.open("shopcat.html");
				}

			}
		})
		$(window).scroll(function() {
			if($('html body').scrollTop() >200) {
//				
				$(oself.ele).css({'left':$(window).width()-60 ,'display':'block'})
			}else{
				$(oself.ele).css('display','none')
			}
		})
}


function ZoomTool(selector){
	this.ele = $(selector).get(0);
	this.selectNode = $(this.ele).find('.main_select').get(0);
	this.Zoomhover();
	this.ZoomAction();
}

ZoomTool.prototype.ZoomAction = function(){
	
	var oSelf = this;
	
	$(oSelf.ele).find('.main_hide').on({
		'mouseenter mouseleave':function(){
			//显示隐藏大图和移动框
			$(oSelf.ele).find('.main_big, .main_select').toggle();
		},
		'mousemove':function(oEvent){
			var left = oEvent.offsetX - $(oSelf.selectNode).width() / 2;
			var top = oEvent.offsetY - $(oSelf.selectNode).height() / 2;
			
			if(left <= 0){
				left = 0;
			}else if(left >= $(this).width() - $(oSelf.selectNode).width() ){
				left = $(this).width() - $(oSelf.selectNode).width()
			}
			
			if(top <= 0){
				top = 0;
			}else if(top >= $(this).height() - $(oSelf.selectNode).height() ){
				top = $(this).height() - $(oSelf.selectNode).height()
			}
			
			//修改移动框的位置
			$(oSelf.selectNode).css({
				left:left,
				top:top
			})
			
			//修改大图的位置
			var scale = $(oSelf.ele).find('.main_big').width() / $(oSelf.selectNode).width();
			
			$(oSelf.ele).find('.main_big').css({
				backgroundPositionX: -left * scale,
				backgroundPositionY: -top * scale,
			})
			
		}
	})
	
}
ZoomTool.prototype.Zoomhover = function(){
	var oSelf = this;
	
	$(oSelf.ele).find('.main_scrolllist li').on({
		'mouseenter':function(){
			this.index=$(this).index();
			num=this.index+1;
			$(oSelf.ele).find('.main_big,.main_small ').css({'background':'url(../img/detailspage/showbig'+num+'.jpg)','background-repeat':'no-repeat'});
			$(oSelf.ele).find('.main_small ').css('background-size','cover');
		},
	})
}

function Selectarea(selector){
	this.ele = $(selector).get(0);
	this.EreaAction();

}
Selectarea.prototype.EreaAction=function(){
	var _this=this;
	
	$(_this.ele).find('p').on({
		'click':function(){

			var j=2;
			this.index=$(this).index();
			var onself=this;

			
			$(_this.ele).find('div div').eq(this.index-2).css('display','block').siblings().css('display','none');
			if(this.index-j<$(_this.ele).find('p').length){
				$(_this.ele).find('div div ul li').on({				
					'click':function(){
						$(_this.ele).find('p').eq(onself.index-j).find('i').html($(this).html());
						$(_this.ele).find('div div').css('display','none');
			
						j--;
					}
				})
				
			}
		}
		
		
	})
}
//吸顶效果
function SuctionTop(selector){
	this.ele = $(selector).get(0);
	this.SuctionFix();
	this.GoTop();
}
SuctionTop.prototype.SuctionFix=function(){
	var _oSelf=this;
	$(window).scroll(function() {
		//console.log($('html body').scrollTop())
			if($('html body').scrollTop() >900) {
			$(_oSelf.ele).find('.main_listdetails').css({'position':'fixed','top':0});
			$(_oSelf.ele).find('.main_listdetails #add').attr('class','selectnone');		
	}else if($('html body').scrollTop() <900){
		$(_oSelf.ele).find('.main_listdetails').css('position','initial');
		$(_oSelf.ele).find('.main_listdetails #add').removeClass();
		
	}
	})
}
//点击切换
SuctionTop.prototype.GoTop=function(){
	var _oSelf=this;
		$(_oSelf.ele).find('.main_listdetails li').on({
				'click':function(){
					this.index=$(this).index();
					$('html body').scrollTop(900);
					$(_oSelf.ele).find('.main_listdetails li').removeClass();
					$(_oSelf.ele).find('.main_listdetails li').eq(this.index).attr('class','main_bottom_select');
					if(this.index==0){
						$(_oSelf.ele).find('.deliverytime,.aftersales,.payment').css('display','none');
						$(_oSelf.ele).find('.godsdetails,.main_evaluation,.bottomconsult').css('display','block');
					}else if(this.index==1){
						$(_oSelf.ele).find('.aftersales,.godsdetails,.main_evaluation,.bottomconsult,.payment').css('display','none');
						$(_oSelf.ele).find('.deliverytime').css('display','block');
					}else if(this.index==2){
						$(_oSelf.ele).find('.aftersales,.godsdetails,.main_evaluation,.bottomconsult,.deliverytime').css('display','none');
						$(_oSelf.ele).find('.payment').css('display','block');
					}else if(this.index==3){
						$(_oSelf.ele).find('.payment,.godsdetails,.main_evaluation,.bottomconsult,.deliverytime').css('display','none');
						$(_oSelf.ele).find('.aftersales').css('display','block');
					}else if(this.index==4){
						$(_oSelf.ele).find('.aftersales,.payment,.godsdetails,.bottomconsult,.deliverytime').css('display','none');
						$(_oSelf.ele).find('.main_evaluation').css('display','block');
					}else if(this.index==5){
						$(_oSelf.ele).find('.aftersales,.payment,.main_evaluation,.godsdetails,.deliverytime').css('display','none');
						$(_oSelf.ele).find('.bottomconsult').css('display','block');
					}else if(this.index==7){
						location.replace("shopcat.html");
					}
				}
			})
}


//点击滚动
function Clickscroll(selector){
	this.ele = $(selector).get(0);
	this.Clickscrolltop();
}
Clickscroll.prototype.Clickscrolltop=function(){
	_onself=this;
	var num=0;
	$(this.ele).find('b').on({
		'click':function(){

			$(_onself.ele).height(853);
			$(_onself.ele).find('ul,.toplist').height(685);
			if(this.id=='top'){
	
					num-=3;
					if(num<=-3){
						num=0;	
					}
					$(_onself.ele).find('ul li').css('display','none');
					$(_onself.ele).find('ul li').eq(num).css('display','block');
					$(_onself.ele).find('ul li').eq(num+1).css('display','block')
					$(_onself.ele).find('ul li').eq(num+2).css('display','block')
					
				}
				if(this.id=='bottom'){
					console.log(num)
					num+=3;
					 if($(_onself.ele).find('ul li').size()<num){
						num=$(_onself.ele).find('ul li').size();
					}
					$(_onself.ele).find('ul li').css('display','none');
					$(_onself.ele).find('ul li').eq(num).css('display','block');
					$(_onself.ele).find('ul li').eq(num-1).css('display','block')
					$(_onself.ele).find('ul li').eq(num-2).css('display','block')
				}	
		}
	})
}

//点击滚动
function Clickscroll_a(selector){
	this.elen = $(selector).get(0);
	this.Clickscrolltop2();
}
Clickscroll_a.prototype.Clickscrolltop2=function(){
	onself=this;
	var num=0;
	$(this.elen).find('b').on({
		'click':function(){
			if(this.id=='top1'){
					num-=6;
					if(num<=-6){
						num=0;	
					}
						$(onself.elen).find('ul li').css('display','none');
					$(onself.elen).find('ul li').eq(num).css('display','block');
					$(onself.elen).find('ul li').eq(num+1).css('display','block')
					$(onself.elen).find('ul li').eq(num+2).css('display','block')
					$(onself.elen).find('ul li').eq(num+3).css('display','block');
					$(onself.elen).find('ul li').eq(num+4).css('display','block')
					$(onself.elen).find('ul li').eq(num+6).css('display','block')
					
				}
				if(this.id=='bottom1'){
					num+=3;
					 if($(onself.elen).find('ul li').size()<num){
						num=$(onself.ele).find('ul li').size()-1;
					}
					$(onself.elen).find('ul li').css('display','none');
					$(onself.elen).find('ul li').eq(num).css('display','block');
					$(onself.elen).find('ul li').eq(num-1).css('display','block')
					$(onself.elen).find('ul li').eq(num-2).css('display','block')
					$(onself.elen).find('ul li').eq(num-3).css('display','block');
					$(onself.elen).find('ul li').eq(num-4).css('display','block')
					$(onself.elen).find('ul li').eq(num-5).css('display','block')
				}	
		}
	})
}



function ShopAdd(selector){
	this.elen = $(selector).get(0);
	this.addcard();
}
ShopAdd.prototype.addcard=function(){
	_oSelf=this;
	$(_oSelf.elen).find('.btnshop a').click(function(){
			if(getCookie('shoplist')){
			var arr = JSON.parse(getCookie('shoplist'));
			}else{
				var arr=[];
			
			}
				var obj={}
				obj.img=$(_oSelf.elen).find('.giftimg').attr("src");
				obj.name=$(_oSelf.elen).find('.giftname').html();
				obj.have=$(_oSelf.elen).find('.gifthave').html();
				obj.highprice=$(_oSelf.elen).find('.bigcount').html();
				obj.price=$(_oSelf.elen).find('.count').html();
				obj.count=1;
			arr.push(obj);
		setCookie('shoplist',JSON.stringify(arr),{ expires:7,path:'/'});
			if(this.id=='buynow1'){
				location.href='shopcat.html'
			}
			if(this.id=='shopcat'){
				alert('加入购物车成功')
			}
		
	})
}
function Skip(selector){
	this.ele = $(selector).get(0);
	$(this.ele).find('li').on({
			'click':function(){
				this.index=$(this).index();
				if(this.index==7){
					location.href="insidepages.html";
				}
			}
	})
}
function Getnum(selector){
	this.elen = $(selector).get(0);
	this.Count();
}
Getnum.prototype.Count=function(){
	var onself=this;
	var num=Math.ceil(Math.random()*9)*1000+Math.ceil(Math.random()*999);
	$(onself.elen).find('.randomcount').html(num);
	$(onself.elen).find('i').click(function(){
		var sum=Math.ceil(Math.random()*9)*1000+Math.ceil(Math.random()*999);
		$(onself.elen).find('.randomcount').html(sum);
	})
}
